<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<!--[if IE]>
		<script type="text/javascript" src="/mochaui/scripts/excanvas_r43.js"></script>
	<![endif]-->
 <script type="text/javascript" src="/mochaui/scripts/mootools-1.2.4-core-yc.js"></script>
    <script type="text/javascript" src="/mochaui/scripts/mootools-1.2.4-more-yc.js"></script>
    <script type="text/javascript" src="/mochaui/scripts/mocha.js"></script>
    <link rel="stylesheet" type="text/css" href="/mochaui/themes/default.css" />
<!-- swfupload -->
<link href="/swfupload/resources/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/swfupload/resources/js/swfupload.js" charset="utf-8"></script>
<script type="text/javascript" src="/swfupload/resources/js/filegroupprogress.js" charset="utf-8"></script>
<script type="text/javascript" src="/swfupload/resources/js/swfupload.queue.js" charset="utf-8"></script>
<script type="text/javascript" src="/swfupload/resources/js/fileprogress.js" charset="utf-8"></script>
<script type="text/javascript" src="/swfupload/resources/js/handlers.js" charset="utf-8"></script>


<script type="text/javascript" charset="utf-8">  
//使用swfupload.swf上传文件时以Filedata字段名提交
var swfu; 
window.onload = function () {   
    var settings = {   
        flash_url : "/swfupload/resources/js/swfupload.swf",   
        upload_url: "/data/sc.action",   
        post_params: {   
            "scid" : "uploadfile"   
        },   
        file_size_limit : "1000 MB",   
        file_types : "*",   
        file_types_description : "All Files",   
        file_upload_limit : 100,   
        file_queue_limit : 0,   
        custom_settings : {   
            progressTarget: "divprogresscontainer",
            //progressGroupTarget : "divprogressGroup", 上传总进度条.这个有问题!filegroupprogress.js屏蔽71行
            //progress object
            container_css: "progressobj",
            icoNormal_css: "IcoNormal",
            icoWaiting_css: "IcoWaiting",
            icoUpload_css: "IcoUpload",
            fname_css : "fle ftt",
            state_div_css : "statebarSmallDiv",
            state_bar_css : "statebar",
            percent_css : "ftt",
            href_delete_css : "ftt",

            //sum object
            /*
                页面中不应出现以"cnt_"开头声明的元素
            */
            s_cnt_progress: "cnt_progress",
            s_cnt_span_text : "fle",
            s_cnt_progress_statebar : "cnt_progress_statebar",
            s_cnt_progress_percent: "cnt_progress_percent",
            s_cnt_progress_uploaded : "cnt_progress_uploaded",
            s_cnt_progress_size : "cnt_progress_size"
        },   
        debug: false,   
        auto_upload:true,   
  
     // Button settings
      //  button_image_url: "/swfupload/resources/images/TestImageNoText_65x29.png",
       button_width: "61",
        button_height: "18",
        button_placeholder_id: "spanButtonPlaceHolder",
        button_text: '<span   style="cursor:hand">上传文件</span>',
       // button_text_style: ".theFont { font-size: 12;color:#0068B7; }",
 
       //当文件选择对话框关闭消失时，如果选择的文件成功加入上传队列，那么针对每个成功加入的文件都会触发一次fileQueued
        file_queued_handler: fileQueued,
        //当选择文件对话框关闭消失时，如果选择的文件加入到上传队列中失败，那么针对每个出错的文件都会触发一次fileQueueError
        file_queue_error_handler: fileQueueError,
		//在文件往服务端上传之前触发此事件，可以在这里完成上传前的最后验证以及其他你需要的操作
        upload_start_handler: uploadStart,
		//该事件由flash定时触发，提供三个参数分别访问上传文件对象、已上传的字节数，总共的字节数
        upload_progress_handler: uploadProgress,
		//无论什么时候，只要上传被终止或者没有成功完成，那么该事件都将被触发
        upload_error_handler: uploadError,
		//当文件上传的处理已经完成（这里的完成只是指向目标处理程序发送了Files信息，只管发，不管是否成功接收），并且服务端返回了200的HTTP状态时，触发此事件。
        upload_success_handler: uploadSuccess,
        upload_complete_handler:uploadComplete,
		//当选择文件对话框关闭，并且所有选择文件已经处理完成（加入上传队列成功或者失败）时，fileDialogComplete被触发
        file_dialog_complete_handler: fileDialogComplete
    };   
   
    swfu = new SWFUpload(settings);   
}   

 


</script>
<body>

<div id = "div.filemanager.upfilelist">
<form method="post" enctype="multipart/form-data">
	<table width="90%" cellspacing="0" cellpadding="0" border="0">
		<tr><td><a href='#' ><span id="spanButtonPlaceHolder"></span></a> &nbsp;&nbsp; 
					<a href='#' ><span id="filemanager_del" >删除文件</span></a>
					<div  id="waitting" STYLE=" position: absolute; width: 200; height: 49;top:50%;left:50%;margin:0px 0 0 -100px;"></div>
		</td></tr>
	</table>
	<table id="idFileList" class="uploadFileList">
		<tr class="uploadTitle">
			<td><div id="divprogresscontainer"></div>
				<!-- <div id="divprogressGroup"></div> -->
			</td>
		</tr>
	</table>
</form>
</div>



<!--
下面显示所有已上传文件列表
-->
<div id="div.allfilelist" style="width:100%" ></div>

</body>

<script type="text/javascript">
var dataURL = '/data/sc.action';//取数据的url
var dataURLParams;
var allfilelist;
var loadAllfileList = function(){
	dataURLParams = {"scid":"filemanagers"};//要传给dataURL的参数
	var instanceName = 'allfilelist';//MUI.List实例名称
	var columns = [{text:'序号',name:'id'},{text:'文件名',name:'filename_url',URL:'filename_url'},
			{text:'大小',name:'sizes'},{text:'上传时间',name:'uptime'}];//要显示的字段
	if (!allfilelist){
		allfilelist = new MUI.List({
			instanceName:instanceName,
	       	container:'div.allfilelist',
	       	showCheckBox:true,
			showCommand:false,
	       	id:'id_allfilelist',
	       	columns:columns,
	       	dataURL:dataURL,
	       	dataURLParams:dataURLParams 
	   	});//MUI.List
   	}
   	allfilelist.setDataURLParams(dataURLParams);
	allfilelist.findList(1,true);
}
window.addEvent('domready', function() {
	new MUI.Require({
		  js: [MUI.path.plugins + 'mochaList/List.js'],
		  onload: function(){
				loadAllfileList();
		  }//onload
	});//MUI.Require
	
	$('filemanager_del').addEvent('click', function(e){
	 		if(allfilelist.checkIds()>=1){
				var confirm = confirmWindow('删除文件','确定要删除选中的文件？<input id="comfirm" type="button" value="确定" ><input id="cancel" type="button" value="取消" >');
				$('comfirm').addEvent('click',function(e){
					confirm.close();
					var itemarr = allfilelist.findIds();
					var del_ids = allfilelist.arrCbToStr(itemarr);	
					dataURLParams = {"scid":"filemanager_del","del_ids":del_ids}; 
					$('filemanager_del').set('disabled', true);
					$('waitting').innerHTML = '<img src="images/spinner.gif" width="16px" height="16px">';
					try {
						var request = new Request.JSON({
							url: dataURL,
							onComplete: function(json,text) {
								if (json.error.errorcode==0){
					 				MUI.notification('删除成功！');
					 				 loadAllfileList();
									$('filemanager_del').set('disabled', false);
					 			}else{
					 				MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
					 				 $('filemanager_del').set('disabled', false);
					 			}
							}
						}).get(dataURLParams);
					} catch (ex) {
						$('filemanager_del').set('disabled', false);
						MUI.notification('<font color=red>错误：</font>访问失败('+ex.message+')');
					}
				});	//comfirm.click
					
				$('cancel').addEvent('click',function(e){
					confirm.close();
				});
		  }else{
			MUI.notification('<font color=red>错误：</font>至少选择一条记录！');
			return;
		  }
	});
	
	 
	
confirmWindow = function(title,content){
	var confirmWindow = new MUI.Window({
	id: 'confirmWindow',
	title: title,
	loadMethod: 'html',
	//contentURL: 'pages/lipsum.html',
	content: content,
	width: 340,
	height: 150,
	minimizable:false,
	maximizable:false
	});
	return confirmWindow;
}
}); //domready
</script>